Ti.include("class/config.js");
Ti.App.config = config;
Ti.include("class/wellcome.js");
Ti.include('class/user.js');
Ti.include('class/db.js');
Ti.include('class/network_user.js');

Ti.App.db = Ti.Database.open(Db.databaseName);
Ti.App.user = user;
Ti.App.network_user = network_user;

Ti.UI.setBackgroundColor('#000');
Ti.UI.iPhone.statusBarStyle = Ti.UI.iPhone.StatusBar.OPAQUE_BLACK;

//pestanya de noticies
var noticiesTab = Titanium.UI.createTab({
    icon: 'img/tab_noticies.png', title: L("Noticies"),
    window: Titanium.UI.createWindow({ navBarHidden:true, url: 'window/noticiesWindow.js' })
});

//pestanya de calendari
var calendariTab = Titanium.UI.createTab({
    icon: 'img/tab_calendari.png', title: L("Calendari"),
    window: Titanium.UI.createWindow({ navBarHidden:true, url: 'window/calendariWindow.js' })
});

//pestanya de calendari
var ideaListTab = Titanium.UI.createTab({  
    icon: 'img/tab_torrent.png', title: L("Torrent"),
    window: Titanium.UI.createWindow({ navBarHidden:true, url: 'window/ideaListWindow.js' })
});

//preferencies, usuari... 
var settingsTab = Titanium.UI.createTab({  
    icon: 'img/tab_settings.png', title: L("Settings"),
    window: Titanium.UI.createWindow({ navBarHidden:true, url: 'window/settingsWindow.js' })
});
Ti.App.tabGroup = Titanium.UI.createTabGroup({ tabs:[noticiesTab,calendariTab,ideaListTab,settingsTab]});
Ti.App.tabGroup.open();

wellcomeMessage.showFirstTimeMessage();

Ti.App.addEventListener('close',function(e){
    Ti.App.db.close();
});